//
//  AdvisoryCell.m
//  WE
//
//  Created by iMacOne on 15/11/19.
//  Copyright © 2015年 UNOHACHA. All rights reserved.
//

#import "AdvisoryCell.h"
#import "Head.h"

@interface AdvisoryCell ()
@property (nonatomic, strong)UIImageView * aImgeView;
@property (nonatomic, strong)UILabel * disLabel;
@property (nonatomic, strong)UILabel * moreLabel;
@property (nonatomic, strong)UIImageView * chooseImgeView;
@property (nonatomic, strong)UIButton * moreButton;
@property (nonatomic, strong)UIScrollView * scrollView;
@end

@implementation AdvisoryCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        
        self.aImgeView = [[UIImageView alloc] initWithFrame:CGRectMake(margin_5 * Width, margin_10 * Height, margin_20 , margin_20)];
        self.aImgeView.layer.masksToBounds = YES;
        self.aImgeView.layer.cornerRadius = 10;
        self.aImgeView.backgroundColor = [UIColor colorWithRed:0.2601 green:0.7607 blue:0.3368 alpha:1.0];
        _aImgeView.image = [UIImage imageNamed:@"iconfont-zhuanjiayisheng"];
        
        self.disLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.aImgeView.frame) + margin_5 * Width, self.aImgeView.frame.origin.y, margin_90, self.aImgeView.frame.size.height)];
        self.disLabel.font = FONT(14);
        self.disLabel.text = @"推荐咨询专家";
        
        self.moreLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, margin_30, margin_10)];
        self.moreLabel.text = @"更多";
        self.moreLabel.font = FONT(10);
        self.moreLabel.textColor = [UIColor grayColor];
        
        self.chooseImgeView = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_moreLabel.frame) - 5, _moreLabel.frame.origin.y - 2, margin_15, margin_15)];
        //        _chooseImgeView.backgroundColor = DEBUG_CLOLR;
        _chooseImgeView.image = [UIImage imageNamed:@"zanting"];
        self.moreButton = [UIButton buttonWithType:UIButtonTypeCustom];
        self.moreButton.frame = CGRectMake(WindowWidth - margin_64, self.aImgeView.frame.origin.y, margin_48, self.aImgeView.frame.size.height);
        [self.moreButton addTarget:self action:@selector(doClickButton:) forControlEvents:UIControlEventTouchUpInside];
        self.moreButton.tag = 100;
//        self.moreButton.backgroundColor = [UIColor yellowColor];
        [self.moreButton addSubview:self.moreLabel];
        [self.moreButton addSubview:self.chooseImgeView];
        
        
        
        self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_disLabel.frame) + margin_10, WindowWidth, margin_100)];
        _scrollView.contentSize = CGSizeMake(WindowWidth+(70 + 3 *(WindowWidth - 110)/5), margin_100);
        _scrollView.showsHorizontalScrollIndicator = NO;
        _scrollView.backgroundColor = [UIColor whiteColor];
        
        
        for (int i = 0; i < 8; i++) {
            CustomView * customView = [[CustomView alloc] initWithFrame:CGRectMake((i + 1) * 20 +(i  ) *(WindowWidth - 110)/5 , 0, (WindowWidth - 110)/5, margin_100)];
            [customView creatPersonView];
            UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doTap:)];
            [customView addGestureRecognizer:tap];
            customView.tag = 200+i;
//            customView.backgroundColor = [UIColor cyanColor];
            [_scrollView addSubview:customView];
        }
        
        
        [self.contentView addSubview:_scrollView];
        [self.contentView addSubview:self.aImgeView];
        [self.contentView addSubview:self.disLabel];
        [self.contentView addSubview:self.moreButton];
    }
    return self;
}
- (void)doClickButton:(UIButton *)btn
{
    
    [self.delegate doClickBtn:btn.tag cell:self];
}
- (void)doTap:(UITapGestureRecognizer*)tap
{
    
//    NSLog(@"%ld",tap.view.tag);
    [self.delegate doClickBtn:tap.view.tag cell:self];

}



@end
